#!/bin/sh
HPACUCLI_BASEDIR="/opt/hp/hpacucli"
HPACUCLI_LOCKDIR="/var/lock/hpacucli"
HPACUCLI_LOCK="${HPACUCLI_LOCKDIR}/CPQACU_MUTEX"
HPACUCLI_BIN="${HPACUCLI_BASEDIR}/hpacucli.bin"

if pgrep -x "${HPACUCLI_BIN##*/}"; then
        echo "Another instance of hpacucli is running! Stop it first."
        exit 1
fi

if ! [ -f "${HPACUCLI_LOCK}" ]; then
	mkdir -p -m 700 "${HPACUCLI_LOCKDIR}"
	touch "${HPACUCLI_LOCK}"
fi

export LD_LIBRARY_PATH="${HPACUCLI_BASEDIR}"
export ACUXE_LOCK_FILES_DIR="${HPACUCLI_LOCKDIR}/"
exec "${HPACUCLI_BIN}" "${@}"
